import httpClient from "@/utils/request";
import type { CreateMenuParams, MenuTree, UpdateMenuParams } from "./types";

/**
 * 获取菜单树
 */
export function getMenuTree() {
  return httpClient.get<MenuTree[]>("/system/menu/tree");
}

/**
 * 添加菜单
 * @param data 菜单信息
 */
export function addMenu(data: CreateMenuParams) {
  return httpClient.post("/system/menu/add", data);
}

/**
 * 更新菜单
 * @param id 菜单ID
 * @param data 菜单信息
 */
export function updateMenu(id: string, data: UpdateMenuParams) {
  return httpClient.post(`/system/menu/update/${id}`, data);
}

/**
 * 获取菜单详情
 * @param id 菜单ID
 */
export function getMenuDetail(id: string) {
  return httpClient.get<MenuTree>(`/system/menu/detail/${id}`);
}

/**
 * 删除菜单
 * @param id 菜单ID
 */
export function deleteMenu(id: string) {
  return httpClient.post(`/system/menu/delete`, { id });
}

/**
 * 批量删除菜单
 * @param ids 菜单ID数组
 */
export function batchDeleteMenu(ids: string[]) {
  return httpClient.post("/system/menu/delete-batch", { ids: { ids } });
}
